import { type HouseModel } from "@/model/house-model";
import { type PageDataModel } from "@/model/page-data-model";
import request from "@/utils/request";

const HouseAPI = {
  /**
   * 获取分页列表
   * @param queryParams 查询参数
   */
  getPage(queryParams: any) {
    return request<any, PageDataModel<HouseModel[]>>({
      url: "/admin/user/apartmentRenderingsList",
      method: "post",
      data: queryParams,
    });
  },

  /**
   * @description 获取列表 不分页
   * @returns Promise<HouseModel[]>
   */
  getList() {
    return request<any, HouseModel[]>({
      url: "/admin/user/apartmentRenderingsSelectList",
      method: "post",
    });
  },

  /**
   * @description 添加户型
   * @param data 户型信息
   * @returns void
   */
  add(data: HouseModel) {
    return request({
      url: "/admin/user/addApartmentRenderings",
      method: "post",
      data,
    });
  },

  /**
   * @description 编辑户型
   * @param data 户型信息
   * @returns void
   */
  edit(data: HouseModel) {
    return request({
      url: "/admin/user/editApartmentRenderings",
      method: "post",
      data,
    });
  },

  /**
   * @description 详情
   * @param id ID
   * @returns Promise<HouseModel>
   */
  detail(id: number) {
    return request<any, HouseModel>({
      url: "/admin/user/apartmentRenderingsDetail",
      method: "post",
      data: { id },
    });
  },

  /**
   * @description 删除
   * @param id ID
   * @returns Promise
   */
  delete(id: number) {
    return request<any, any>({
      url: "/admin/user/delApartmentRenderings",
      method: "post",
      data: { id },
    });
  },

  /**
   * @description 设置用户的户型
   * @param {number} id 用户ID
   * @param {number} house_id 户型ID
   */
  setUserHouse(id: number | string, house_id: number) {
    return request<any, any>({
      url: "/admin/user/editUserApartmentRenderings",
      method: "post",
      data: { id, apartment_id: house_id },
    });
  },
};

export default HouseAPI;
